
const _interopRequireDefault = require('@babel/runtime/helpers/interopRequireDefault');

exports.__esModule = true;
exports.default = void 0;

const _babelHelperVueJsxMergeProps = _interopRequireDefault(require('@vue/babel-helper-vue-jsx-merge-props'));

const _utils = require('../utils');

const _functional = require('../utils/functional');

const _constant = require('../utils/constant');

const _icon = _interopRequireDefault(require('../icon'));

// Utils
// Components
const _createNamespace = (0, _utils.createNamespace)('tag');
const createComponent = _createNamespace[0];
const bem = _createNamespace[1];

function Tag(h, props, slots, ctx) {
  let _style; let
    _ref;

  const { type } = props;
  const { mark } = props;
  const { plain } = props;
  const { color } = props;
  const { round } = props;
  const { size } = props;
  const key = plain ? 'color' : 'backgroundColor';
  const style = (_style = {}, _style[key] = color, _style);

  if (props.textColor) {
    style.color = props.textColor;
  }

  const classes = {
    mark,
    plain,
    round,
  };

  if (size) {
    classes[size] = size;
  }

  const CloseIcon = props.closeable && h(_icon.default, {
    attrs: {
      name: 'cross',
    },
    class: bem('close'),
    on: {
      click: function click(event) {
        event.stopPropagation();
        (0, _functional.emit)(ctx, 'close');
      },
    },
  });
  return h('transition', {
    attrs: {
      name: props.closeable ? 'van-fade' : null,
    },
  }, [h('span', (0, _babelHelperVueJsxMergeProps.default)([{
    key: 'content',
    style,
    class: [bem([classes, type]), (_ref = {}, _ref[_constant.BORDER_SURROUND] = plain, _ref)],
  }, (0, _functional.inherit)(ctx, true)]), [slots.default == null ? void 0 : slots.default(), CloseIcon])]);
}

Tag.props = {
  size: String,
  mark: Boolean,
  color: String,
  plain: Boolean,
  round: Boolean,
  textColor: String,
  closeable: Boolean,
  type: {
    type: String,
    default: 'default',
  },
};

const _default = createComponent(Tag);

exports.default = _default;
